import { storage } from './storage'

export const getTime = () => {
  let message = ''
  const hours = new Date().getHours()
  if (hours <= 9) {
    message = '早上'
  } else if (hours <= 12) {
    message = '上午'
  } else if (hours <= 18) {
    message = '下午'
  } else {
    message = '晚上'
  }
  return message
}

const timeKey = 'hrsaas-timestamp-key' // 设置唯一的key

// 获取时间戳
export const getTimeStamp = () => {
  return storage.get(timeKey)
}
// 设置时间戳
export const setTimeStamp = () => {
  storage.set(timeKey, Date.now())
}
// 是否超时
const TimeOut = 3600 // 定义超时时间 
export const IsCheckTimeOut = () => {
  const currentTime = Date.now() // 当前时间戳
  const timeStamp = getTimeStamp() // 缓存时间戳
  return currentTime - timeStamp > TimeOut
}